<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>驴妈妈统计系统</title>
		<meta name="description" content="overview &amp; stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/bootstrap.min.css" />
		<link rel="stylesheet" href="${request.contextPath}/static/assets/font-awesome/4.5.0/css/font-awesome.min.css" />
		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/daterangepicker.min.css" />
		<!-- text fonts -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/fonts.googleapis.com.css" />
		<!-- ace styles -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style" />
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace-skins.min.css" />
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace-rtl.min.css" />
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/jquery.gritter.min.css" />
		<!-- ace settings handler -->
		<script src="${request.contextPath}/static/assets/js/ace-extra.min.js"></script>
	</head>

	<body class="skin-2" style="background-color: #FFF;">
		<div class="page-content">
			<!-- <div class="page-header">
				<h1>
					用户管理
					<small>
						<i class="ace-icon fa fa-angle-double-right"></i>
						用户列表
					</small>
				</h1>
			</div> -->
			<div class="row">
				<div class="col-xs-12">
					<div class="clearfix">
						<div class="pull-left tableTools-container">
							<button class="btn btn-xs btn-primary" onclick="skip('${request.contextPath}/newUser')"><i class="ace-icon fa fa-pencil-square-o align-top bigger-125"></i>新增</button>
						</div>
					</div>
					<!-- PAGE CONTENT BEGINS -->
					<div id="dynamic-table_wrapper" class="dataTables_wrapper form-inline no-footer">
						<table id="dynamic-table" class="table table-striped table-bordered table-hover dataTable no-footer" role="grid" aria-describedby="dynamic-table_info">
							<thead>
								<tr>
									<th>No.</th>
									<th>登录名</th>
									<th>姓名</th>
									<th>邮箱</th>
									<th>电话</th>
									<th>是否允许登录</th>
									<th>最后登陆日期</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<#list users as user>
									<tr class="">
										<td>${user_index + 1}</td>
										<td>${user.username!}</td>
										<td>${user.characterName!}</td>
										<td>${user.email!}</td>
										<td>${user.phone!}</td>
										
										<td>
										<#if user.isEnable==1>
														是
													<#else>
														否
													</#if>
										</td>
										
										<#if user.operateDate??>
										<td>${user.operateDate?string('yyyy-MM-dd HH:mm:ss')}</td>
										<#else>
										<td>从未登录</td>
										</#if>
										<td>
											<input type="hidden" id="user" name="user" value="${user.id}">
											<a class="btn btn-minier btn-primary" href="${request.contextPath}/editUser?id=${user.id!}" role="button">编辑</a>
											<button class="btn btn-minier btn-danger" onclick="deleteUser(this)" role="button">删除</button>
											<#if user.isEnable==1>
											<a class="btn btn-minier btn-primary" href="${request.contextPath}/enableUser?id=${user.id!}&isEnable=0" role="button">停用</a>
											<#else>
											<a class="btn btn-minier btn-primary" href="${request.contextPath}/enableUser?id=${user.id!}&isEnable=1" role="button">启用</a>
											</#if>
										</td>
									</tr>
								</#list>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
		<input type="hidden" id="userlistcontext" value="${request.contextPath}"/>
		<script src="${request.contextPath}/static/assets/js/jquery-2.1.4.min.js"></script>
		<script type="text/javascript">
			if('ontouchstart' in document.documentElement) document.write("<script src='${request.contextPath}/static/assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
			
		</script>
		<script src="${request.contextPath}/static/assets/js/bootstrap.min.js"></script>

		<!-- page specific plugin scripts -->
		<script src="${request.contextPath}/static/assets/js/jquery-ui.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/jquery.ui.touch-punch.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/jquery.gritter.min.js"></script>

		<!-- ace scripts -->
		<script src="${request.contextPath}/static/assets/js/ace-elements.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/ace.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/bootbox.js"></script>
		<!-- user scripts -->
		<script src="${request.contextPath}/static/assets/js/user/base.js"></script>
		<script type="text/javascript">
			var userlistcontext = $("#userlistcontext").val();
			function deleteUser(object){
				var userid = $(object).parent().children().eq(0).val();
				if(userid=='1'){
					bootbox.alert("超级管理员不允许被删除！");
					return;
				}
				
				
				bootbox.confirm("<strong style='font-size:15px;padding-left:200px'>删除后数据不可恢复，确认删除用户吗？</strong>", function(result){
					if(result){
						$.ajax({
							url : userlistcontext+'/deleteUser?id='+userid,
							type : "GET",
							async: false,
							success:function(data) {
								if(data.sessionStatus==540){//异步请求session过期状态
									window.location.href=userlistcontext+"/login";
								}else{
									$(object).parents("tr").remove();
								}
							},
							error:function(data) {
							}
						});
					}
				});
				
			}

		</script>
	</body>
</html>